package org.gwu.seuss.server.command;

import org.apache.log4j.Logger;
import org.gwu.seuss.communication.request.ClientRequest;
import org.gwu.seuss.communication.request.ServerResponse;
import org.gwu.seuss.service.FileService;
import org.gwu.seuss.service.ServiceFactory;
import org.gwu.seuss.service.UserService;
import org.gwu.seuss.service.UsersSharedFilesService;

public class UserCommandBase {

	static Logger log = Logger.getLogger(UserCommandBase.class);

	protected ClientRequest req;
	
	protected UserService userService = ServiceFactory.getUserService();
	protected FileService fileService = ServiceFactory.getFileService();
	protected UsersSharedFilesService usersSharedFilesService = ServiceFactory.getUsersSharedFilesService();
	
	public UserCommandBase(ClientRequest req){
		this.req = req;
	}
	
	protected ServerResponse getServerResponse(int result, String message){
		ServerResponse rep = new ServerResponse();
		if(result > 0) {
			log.info(message);
			rep.setMessage(message);
			rep.setSuccess(true);
		}
		return rep;
	}
	
	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	
	public void setFileService(FileService fileService) {
		this.fileService = fileService;
	}

	public void setUsersSharedFilesService(
			UsersSharedFilesService usersSharedFilesService) {
		this.usersSharedFilesService = usersSharedFilesService;
	}
}